package service

import (
	"singo/model"
	"singo/serializer"
)

// MistakeShowService 错误日志详情的服务
type MistakeShowService struct {
}

// MistakeShow 错误日志
func (service *MistakeShowService) MistakeShow(uid string) serializer.Response {
	var mistake model.Mistake
	err := model.DB.First(&mistake, "id = ?", uid).Error
	if err != nil {
		return serializer.Response{
			Status: 404,
			Msg:    "错误日志不存在",
			Error:  err.Error(),
		}
	}

	return serializer.Response{
		Data: serializer.BuildMistake(mistake),
	}
}
